// 临时定义，避免导入错误
interface TAnalyticsContainProps {
  // 分析相关属性
}
import React from 'react';
import {
  Animated,
  ColorValue,
  GestureResponderEvent,
  ImageLoadEventData,
  ImageProps,
  ImageResizeMode,
  NativeSyntheticEvent,
  TextInput,
  TextInputProps,
  TextProps,
  TouchableOpacityProps,
  View,
  ViewProps,
} from 'react-native';

export type TStringNumber = number | string | undefined;

export interface TContainerPropsBase {
  /**
   * flex , if true, {flex:1} will be configed.
   */
  f?: boolean | TStringNumber;
  /**
   * flexGrow, if true, {flex:1} will be configed.
   */
  fg?: boolean | TStringNumber;
  /**
   * flexDirection="row"
   */
  row?: boolean;
  /**
   * justifyContent
   *
   * c=center, fs=flex-start, fe=flex-end, sb=space-between, sa=space-around, se=space-evenly
   */
  jc?: 'c' | 'fs' | 'fe' | 'sb' | 'sa' | 'se';
  /**
   * alignItems
   *
   * fs=flex-start, fe=flex-end, c=center, s=stretch, b=baseline;
   */
  ai?: 'fs' | 'fe' | 'c' | 's' | 'b';
  /**
   * alignSelf
   *
   * fs=flex-start, fe=flex-end, c=center, s=stretch, b=baseline;
   */
  as?: 'fs' | 'fe' | 'c' | 's' | 'b';
  /**
   * flexWrap="wrap"
   */
  wrap?: boolean;
  /**
   * flexWrap="wrap"
   */
  fwp?: boolean;
  /**
   * overflow="hidden"
   */
  of?: boolean;
  /**
   * width
   */
  w?: TStringNumber;
  /**
   * height
   */
  h?: TStringNumber;
  /**
   * width and height
   */
  wh?: TStringNumber;
  /**
   * width height and borderRadius
   */
  whr?: TStringNumber;
  /**
   * maxWidth
   */
  maxW?: TStringNumber;
  /**
   * minWidth
   */
  minW?: TStringNumber;
  /**
   * maxHeight
   */
  maxH?: TStringNumber;
  /**
   * minHeight
   */
  minH?: TStringNumber;

  /**
   * marginHorizontal
   */
  mh?: TStringNumber;
  /**
   * marginVertical
   */
  mv?: TStringNumber;
  /**
   * marginTop
   */
  mt?: TStringNumber;
  /**
   * marginBottom
   */
  mb?: TStringNumber;
  /**
   * marginLeft
   */
  ml?: TStringNumber;
  /**
   * marginRight
   */
  mr?: TStringNumber;
  /**
   * margin
   * support array:[m] or [mh, mv] or [mt, mh, mb] or [mt, mr, mb, ml]
   */
  m?: TStringNumber | TStringNumber[];

  /**
   * paddingHorizontal
   */
  ph?: TStringNumber;
  /**
   * paddingVertical
   */
  pv?: TStringNumber;
  /**
   * paddingTop
   */
  pt?: TStringNumber;
  /**
   * paddingBottom
   */
  pb?: TStringNumber;
  /**
   * paddingLeft
   */
  pl?: TStringNumber;
  /**
   * paddingRight
   */
  pr?: TStringNumber;
  /**
   * padding
   * support array:[p] or [ph, pv] or [pt, ph, pb] or [pt, pr, pb, pl]
   */
  p?: TStringNumber | TStringNumber[];
  /**
   * borderTopWidth
   */
  bwt?: TStringNumber;
  /**
   * borderBottomWidth
   */
  bwb?: TStringNumber;
  /**
   * borderLeftWidth
   */
  bwl?: TStringNumber;
  /**
   * borderRightWidth
   */
  bwr?: TStringNumber;
  /**
   * borderWidth
   * support array: [bwt, bwr, bwb, bwl]
   */
  bw?: TStringNumber | TStringNumber[];
  /**
   * borderTopColor
   */
  bct?: ColorValue;
  /**
   * borderBottomColor
   */
  bcb?: ColorValue;
  /**
   * borderLeftColor
   */
  bcl?: ColorValue;
  /**
   * borderRightColor
   */
  bcr?: ColorValue;
  /**
   * borderColor
   * support array: [bct, bcr, bcb, bcl]
   */
  bc?: ColorValue | ColorValue[];
  /**
   * borderTopLeftRadius
   */
  brtl?: TStringNumber;
  /**
   * borderTopRightRadius
   */
  brtr?: TStringNumber;
  /**
   * borderBottomLeftRadius
   */
  brbl?: TStringNumber;
  /**
   * borderBottomRightRadius
   */
  brbr?: TStringNumber;
  /**
   * borderRadius
   *
   * support array: [brtl, brtr, brbl, brbr]
   */
  br?: TStringNumber | TStringNumber[];
  /**
   * border. should be [bw, bc, br]. bc and br is not required.
   *
   * Array support:
   * bw: [bwt, bwr, bwb, bwl],
   * bc: [bct, bcr, bcb, bcl],
   * br: [brtl, brtr, brbl, brbr]
   */
  b?: (TStringNumber | TStringNumber[])[];
  /**
   * backgroundColor
   */
  bg?: ColorValue;
  /**
   * opacity (support Animated.Value)
   */
  op?: TBasicAnimatedValue<number>;
  /**
   * transform: [{translateX}], (support Animated.Value)
   */
  tx?: TBasicAnimatedValue<number>;
  /**
   * transform: [{translateY}], (support Animated.Value)
   */
  ty?: TBasicAnimatedValue<number>;
  /**
   * transform: [{scale}], (support Animated.Value)
   */
  scale?: TBasicAnimatedValue<number>;
  /**
   * transform: [{scaleX}], (support Animated.Value)
   */
  sx?: TBasicAnimatedValue<number>;
  /**
   * transform: [{scaleY}], (support Animated.Value)
   */
  sy?: TBasicAnimatedValue<number>;
  /**
   * transform: [{rotate}], (support Animated.Value)
   */
  rt?: TBasicAnimatedValue<number | string>;
  /**
   * Set position to absolute if pos is configed.
   * The array is [top, left, bottom, right]. They are not required. Empty array is allowed.
   */
  pos?: TStringNumber | TStringNumber[];
  /**
   * justifyContent=space-around
   */
  sa?: boolean;
  /**
   * justifyContent=space-between
   */
  sb?: boolean;
  /**
   * zIndex
   */
  z?: TStringNumber;
  /**
   * Is it safe area view?
   */
  sf?: boolean;
  /**
   * shadow radius. see https://ethercreative.github.io/react-native-shadow-generator/
   */
  sd?: boolean | 'top';
  /**
   * Use a TouchableOpacity component instead of View if onPress is configed.
   */
  onPress?: (evt: GestureResponderEvent) => void;
  /**
   * disabled on TouchableOpacity;
   */
  disabled?: boolean;
  /**
   * NoFeedback: Use a TouchableWithoutFeedback component instead of
   * TouchableOpacity if onPress is configed.
   */
  nf?: boolean;
  /**
   * hitSlot, default is 10 only works on TouchableOpacity (onPress must be configed).
   */
  hs?: TStringNumber;
  /**
   * use react-native's TouchableOpacity instead of react-native-gesture-handler's.
   */
  rn?: boolean;
  /**
   * use react-native-gesture-handler's TouchableOpacity instead of react-native's.
   */
  ges?: boolean;
  /**
   * ref of the container
   */
  innerRef?: React.RefObject<View>;
}

export type TContainerProps = TContainerPropsBase &
  ViewProps &
  TouchableOpacityProps &
  TAnalyticsContainProps;

export type TFontWeight =
  | 'normal'
  | 'bold'
  | '100'
  | '200'
  | '300'
  | '400'
  | '500'
  | '600'
  | '700'
  | '800'
  | '900';

export interface TTProps extends TContainerPropsBase, TextProps {
  /**
   * color, default is #060506
   */
  c?: ColorValue;
  /**
   * fontFamily
   */
  ff?:
    | 'Inter'
    | 'GT Flexa Trial'
    | 'TT Commons'
    | 'TT-Commons-Regular'
    | 'TT-Commons-Bold'
    | 'CoolveticaRg-Regular'
    | 'Raleway Dots'
    | 'CoolveticaRg-Italic';
  /**
   * fontWeight, default is 500
   */
  fw?: TFontWeight;
  /**
   * fontSize, default is 16
   */
  fs?: TStringNumber;
  /**
   * lineHeight
   */
  lh?: TStringNumber;
  /**
   * textAlign
   */
  ta?: 'left' | 'right' | 'center';
  /**
   * numberOfLines, default is 1.
   */
  nol?: TStringNumber;
  /**
   * ellipsizeMode, default is tail.
   */
  em?: 'head' | 'middle' | 'tail' | 'clip';
  /**
   * under line color, in react native style: {textDecorationLine: 'underline',textDecorationColor:ulc }
   */
  ulc?: ColorValue;
  /**
   * delete line color, in react native style: {textDecorationLine: 'line-though',textDecorationColor:ulc }
   */
  dlc?: ColorValue;
}

export interface TInputProps extends TTProps, TextInputProps {
  /**
   * placeholder
   */
  phr?: string;
  /**
   * placeholderTextColor
   */
  phc?: ColorValue;
  /**
   * defaultValue
   */
  dv?: string;
  /**
   * ref of the input
   */
  inputRef?: React.LegacyRef<TextInput>;
}

type TFilteredImageProps = Omit<
  ImageProps,
  'source' | 'defaultSource' | 'resizeMode'
>;

export interface TImgProps extends TContainerPropsBase, TFilteredImageProps {
  /**
   * source
   */
  src: string;
  /**
   * defaultSource
   */
  dsrc?: string | number;
  /**
   * resizeMode
   */
  rm?: ImageResizeMode;
  /**
   * resizeMethod
   */
  rmd?: 'auto' | 'resize' | 'scale';
  /**
   * tintColor
   */
  tc?: ColorValue;
  /**
   * use React Native Image force
   */
  rn?: boolean;
  /**
   * 子节点
   */
  children?: React.ReactNode;
  /**
   * fix onLoad function bug on FastImage.
   */
  onLoad?: (
    event: NativeSyntheticEvent<
      ImageLoadEventData & { height?: number; width?: number }
    >
  ) => void;
}

export type TBasicAnimatedValue<T extends string | number> =
  | TStringNumber
  | Animated.Value
  | Animated.AnimatedInterpolation<T>;

export interface TAsyncProps extends TContainerProps {
  /**
   * async callback，must return Promise.
   */
  on?: (evt: GestureResponderEvent) => Promise<unknown>;
  /**
   * renderProcessing, a render function for processing.
   */
  rp?: () => React.ReactNode;
  /**
   * 无法点击时的透明度
   */
  disableOp?: number;
  /**
   * 正在处理时的透明度
   */
  processingOp?: number;

  children?: React.ReactNode;

  disabled?: boolean;

  nf?: boolean;
}
